from alg2 import letter_case_permutation
from gen2 import generate_test_cases

def test_basic_cases():
    """测试基本用例"""
    # 测试用例1
    assert set(letter_case_permutation("a1b2")) == set(["a1b2", "a1B2", "A1b2", "A1B2"])
    
    # 测试用例2
    assert set(letter_case_permutation("3z4")) == set(["3z4", "3Z4"])
    
    # 测试用例3：只有字母
    assert set(letter_case_permutation("ab")) == set(["ab", "aB", "Ab", "AB"])
    
    # 测试用例4：只有数字
    assert set(letter_case_permutation("12")) == set(["12"])
    
    print("基本测试用例通过！")

def test_random_cases():
    """测试随机生成的用例"""
    test_cases = generate_test_cases(5)
    
    print("\n随机测试用例：")
    for i, test_case in enumerate(test_cases, 1):
        result = letter_case_permutation(test_case)
        print(f"\n测试 {i}:")
        print(f"输入: {test_case}")
        print(f"输出: {result}")
        print(f"组合数量: {len(result)}")

def verify_result(s, result):
    """验证结果的正确性"""
    # 检查每个结果的长度是否与输入相同
    if not all(len(x) == len(s) for x in result):
        return False
    
    # 检查每个位置的字符是否合法
    for item in result:
        for i, (original, transformed) in enumerate(zip(s, item)):
            if original.isalpha():
                if transformed.lower() != original.lower():
                    return False
            else:
                if transformed != original:
                    return False
    
    return True

if __name__ == "__main__":
    print("开始测试...")
    test_basic_cases()
    test_random_cases()
